From fd69e74cdfd95ab9d5a7fce1d40621744c4c6bf7 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Fri, 12 Mar 2004 16:35:04 +0000 Subject: [PATCH] bitkeeper revision 1.792 (4051e6b8E8mkfvd_6g9fklSAWSPykA) console.c: More robustification. --- xen/drivers/char/console.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index d6c9c8ac25..51070bd5dc 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -235,23 +235,16 @@ static void switch_serial_input(void) { static char *input_str[2] = { "DOM0", "Xen" }; xen_rx = !xen_rx; - printk("\n*** Serial input -> %s " + printk("*** Serial input -> %s " "(type 'CTRL-a' three times to switch input to %s).\n", input_str[xen_rx], input_str[!xen_rx]); } -static void serial_rx(unsigned char c, struct pt_regs *regs) +static void __serial_rx(unsigned char c, struct pt_regs *regs) { key_handler *handler; unsigned long cpu_mask; struct task_struct *p; - static int ctrl_a_count = 0; - - if ( (ctrl_a_count = (c == CTRL_A) ? ctrl_a_count+1 : 0) >= 3 ) - { - switch_serial_input(); - ctrl_a_count = 0; - } if ( xen_rx ) { @@ -271,6 +264,29 @@ static void serial_rx(unsigned char c, struct pt_regs *regs) } } +static void serial_rx(unsigned char c, struct pt_regs *regs) +{ + static int ctrl_a_count = 0; + + if ( c == CTRL_A ) + { + /* We eat CTRL-a in groups of three to switch console input. */ + if ( ++ctrl_a_count == 3 ) + { + switch_serial_input(); + ctrl_a_count = 0; + } + } + else + { + /* Flush any pending CTRL-a's. They weren't for us. */ + for ( ; ctrl_a_count != 0; ctrl_a_count-- ) + __serial_rx(CTRL_A, regs); + /* Finally process the just-received character. */ + __serial_rx(c, regs); + } +} + long do_console_io(int cmd, int count, char *buffer) { char *kbuf; -- 2.30.2